#include<bits/stdc++.h>
#define int long long 
using namespace std;

inline int read() {
	int x = 0, f = 0; char ch = getchar();
	while(ch < '0' or ch > '9') f |= (ch == '-'), ch = getchar();
	while(ch >= '0' and ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
int __stk[128], __top;
inline void write(int x) {
    if(x < 0) putchar('-'), x = -x;
	do { __stk[++__top] = x % 10, x /= 10; } while(x);
	while (__top) putchar(__stk[__top--] + '0');
}
bool stmer;
const int N = 2e6 + 10, mod = 998244353;
void add(int &x, int y) { (x += y) >= mod and (x -= mod); }
void mul(int &x, int y) { x = x * y % mod; }
int q_pow(int x, int k) {
    int res = 1;
    for(; k; k >>= 1, mul(x, x))
        if(k & 1) mul(res, x);
    return res;
}
int n, k, ans = mod - 1;
int fac[N], inv[N], a[N];
int C(int x, int y) { return y > x ? 0 : fac[x] * inv[y] % mod * inv[x - y] % mod; }
void init() {
    fac[0] = 1;
    for(int i = 1; i < N; i++) fac[i] = fac[i - 1] * i % mod;
    inv[N - 1] = q_pow(fac[N - 1], mod - 2);
    for(int i = N - 1; i; i--) inv[i - 1] = inv[i] * i % mod;
}
void work() {
    // for(int i = 0; i < a[1]; i++) {
    //     add(ans, C(n - 1 + k - i - 1, k - i - 1));
    //     cout << C(n - 1 + k - i - 1, k - i - 1) << '\n';
    // }
    // cout << ans << '\n';
    int lat = 0, f = 1;
    for(int i = 1; i <= n; i++) {
        if(a[i] < lat) { f = 0; break; }
        for(int j = lat; j < a[i]; j++)
            add(ans, C(n - i + k - j - 1, k - j - 1));
        lat = a[i];
    }
    if(f) add(ans, 1); write(ans);
}
bool edmer;
signed main() {
	freopen("count.in", "r", stdin);
	freopen("count.out", "w", stdout);
	cerr << "[Memory] " << (&stmer - &edmer) / 1024 / 1024 << " MB\n";
	init(), n = read(), k = read();
    for(int i = 1; i <= n; i++) a[i] = read();
    work();
    cerr << "[Runtime] " << (double) clock() / CLOCKS_PER_SEC << " seconds";
	return 0;
} 